﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using SMSSnew.DATA.CLASSES;
using SMSSnew.CLASSES;

namespace SMSSnew.UI.vicePrincipal.timetable
{
    public partial class vicePrinTtClassView : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                timeTableCLZ objTT = new timeTableCLZ();
               
                DataTable dt1;

                dt1 = objTT.loadGrade();
                
                if (dt1.Rows.Count != 0)
                {
                    for (int i = 0; i < dt1.Rows.Count; i++)
                    {
                        cboGrade.Items.Insert(i, dt1.Rows[i][0].ToString());
                    }
                }

            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            String clas = cboClassID.SelectedValue.ToString();
            try
            {

                DataTable viewClassTimetable = new DataTable();
                timeTableCLZ viewCT = new timeTableCLZ();

                viewCT.viewClassTimetable(clas);

                viewClassTimetable = viewCT.loadClassTimetableToGrid();
                ttClassViewGrid.DataSource = viewClassTimetable;
                ttClassViewGrid.DataBind();

                               
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        protected void cboGrade_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable dt2;
            classCLZ objClass = new classCLZ(cboGrade.SelectedItem.ToString());
            timeTableCLZ objTT = new timeTableCLZ();
            dt2 = objTT.loadClassID(objClass);

            cboClassID.Items.Clear();

            if (dt2.Rows.Count != 0)
            {
                for (int i = 0; i < dt2.Rows.Count; i++)
                {
                    cboClassID.Items.Insert(i, dt2.Rows[i][0].ToString());
                }
            }
        }
    }
}
